package com.zzedu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzedu.domain.ZzCourse;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 课程包管理Mapper接口
 *
 * @author Mr.Wang
 * @date 2025-02-04
 */
public interface ZzCourseMapper extends BaseMapper<ZzCourse> {
    @Select({
            "<script>",
            "SELECT DISTINCT b.* ",
            "FROM zz_classes_send_student a",
            "INNER JOIN zz_course b ON b.id = a.unit_id",
            "INNER JOIN zz_picture_book c ON c.id = a.book_id",
            "WHERE a.deleted = 0",
            "  AND b.deleted = 0",
            "  AND b.state = 0",
            "  AND c.deleted = 0",
            "  <if test='level != null'>AND b.level = #{level}</if>",
            "  <if test='stuId != null'>AND a.stu_id = #{stuId}</if>",
            "  <if test='schoolId != null'>AND a.school_id = #{schoolId}</if>",
            "ORDER BY b.sort_no",
            "</script>"
    })
    List<ZzCourse> getStuCourseListNews(@Param("stuId") Long stuId, @Param("schoolId") Long schoolId, @Param("level") String level, @Param("stateList") List<Integer> stateList);
}
